// Copyright (c) 2020 vesoft inc. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

#ifndef GRAPH_EXECUTOR_QUERY_DATACOLLECTEXECUTOR_H_
#define GRAPH_EXECUTOR_QUERY_DATACOLLECTEXECUTOR_H_

#include "graph/executor/Executor.h"
// DataCollect used to collect multiple versions of results(LOOP operator exist in execution plan)
// OR used after filter operator (the result of the filter operator has no dataset but an iterator)
//
// Member:
//  `colNames_` : save the column name of the result of the DataCollect
// Functions:
//  `collectSubgraph` : receive result from GetNeighbors, collect vertices & edges by calling
//   GetNeighborIter's getVertices & getEdges interface
//
//  `rowBaseMove` : Collect the latest version of the results
//
//  `collectMToN` : Only used in GO MToN scenarios. Collect the results generated by MTON
//  steps (multi-version)
//
//  `collectAllPaths` : Only used in FindPath scenarios. Collect the paths generated by the FindPath
//   operator (multi-version)
//
//  `collectPathProp` : Only used in FindPath scenarios, the input is a collection of vertices and
//   edges with attributes and paths without attributes. then populate the attributes of vertices
//   and edges into paths
namespace nebula {
namespace graph {
class DataCollectExecutor final : public Executor {
 public:
  DataCollectExecutor(const PlanNode* node, QueryContext* qctx)
      : Executor("DataCollectExecutor", node, qctx) {}

  folly::Future<Status> execute() override;

 private:
  folly::Future<Status> doCollect();

  Status collectSubgraph(const std::vector<std::string>& vars);

  Status rowBasedMove(const std::vector<std::string>& vars);

  Status collectMToN(const std::vector<std::string>& vars, const StepClause& mToN, bool distinct);

  Status collectBFSShortest(const std::vector<std::string>& vars);

  Status collectAllPaths(const std::vector<std::string>& vars);

  Status collectPathProp(const std::vector<std::string>& vars);

  std::vector<std::string> colNames_;
  Value result_;
};
}  // namespace graph
}  // namespace nebula
#endif
